﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DmgPlayer : MonoBehaviour
{

    Animator am;
    PlayerController player;

    bool NB;

    public Transform boss;
    void Start()
    {
        am = transform.parent.GetComponent<Animator>();
        player = transform.parent.GetComponent<PlayerController>();
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F12))
        {
            NB = !NB;
        }
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        if (!NB)
        {
            if (other.gameObject.tag.Equals("EnemyArm"))
            {
                am.SetTrigger("Dmg");
                transform.parent.GetComponent<PlayerController>().hp -= other.transform.parent.GetComponent<EnemyController>().Atk;
                player.isDmg = true;
            }

            if (other.gameObject.tag.Equals("EnemyArmBullet"))
            {
                Destroy(other.gameObject);
                am.SetTrigger("Dmg");
                transform.parent.GetComponent<PlayerController>().hp -= boss.GetComponent<Enemy_BOSS_Controller>().atk / 2;
                player.isDmg = true;
            }
        }


    }

}
